Skip to content

freebsd: Increase consistancy with libc implementation#36

Merged
newpavlov merged 1 commit intorust-random:masterfrom
josephlr:freebsd
Jun 19, 2019
Merged

freebsd: Increase consistancy with libc implementation#36
newpavlov merged 1 commit intorust-random:masterfrom
josephlr:freebsd

Conversation

@josephlr
Copy link
Copy Markdown
Member

@josephlr josephlr commented Jun 17, 2019

In #35 @myfreeweb pointed out that the FreeBSD's libc implemenation calls kern_arnd in a loop, and simply retries if the syscall returns a short buffer.

There doesn't seem like a good reason to differ from their implementation, so this PR changes the implementation to be more like the one for Linux getrandom.

@josephlr josephlr mentioned this pull request Jun 17, 2019
@dhardy
Copy link
Copy Markdown
Member

dhardy commented Jun 18, 2019

And yet that implementation still has a limit of 256 bytes, so unless someone wants to check up on the kernel source code we should keep the chunking I think.

@newpavlov
Copy link
Copy Markdown
Member

IIUC if we provide buffer larger than 256 bytes, kernel will fill only first 256 bytes and will return 256. Thus we don't need explicit chunking.

@josephlr
Copy link
Copy Markdown
Member Author

IIUC if we provide buffer larger than 256 bytes, kernel will fill only first 256 bytes and will return 256. Thus we don't need explicit chunking.

This is correct, I also think the the 256 bytes is an implementation detail; I couldn't find documentation for the behavior. In that case, this implementation no longer makes assumptions about how KERN ARND works.

@dhardy
Copy link
Copy Markdown
Member

dhardy commented Jun 19, 2019

In that case, 👍 . Over to you @newpavlov

@newpavlov newpavlov merged commit a91b60b into rust-random:master Jun 19, 2019
@josephlr josephlr deleted the freebsd branch June 23, 2019 06:57
takumi-earth pushed a commit to earthlings-dev/getrandom that referenced this pull request Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants